﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;


namespace SceneEditor
{
    public class MenuControl : MonoBehaviour
    {
        [SerializeField]
        private Button confrimBtn, cancelBtn;

        private Action action;

        void Start()
        {
            confrimBtn.onClick.AddListener(() =>
            {
                if (action != null) action();
            });

            cancelBtn.onClick.AddListener(() =>
            {
                action = null; cancelBtnClick();
            });
        }


        void cancelBtnClick()
        {
            ScreenShotManager.Instance.OnExit();
        }
        public void OnEnter(Vector3 screenPos, Action action)
        {
            Vector3 pos = MonoTool.Instance.ToLocalPos(screenPos);
            transform.localPosition = pos- transform.parent.localPosition;
            this.action = action;
            gameObject.SetActive(true);
        }

        public void OnExit()
        {
            gameObject.SetActive(false);
        }
    }

}
